package com.zycfc.zsf.boot.mq.rabbitmq.config;

import com.zycfc.zsf.boot.mq.rabbitmq.retry.*;
import org.springframework.boot.actuate.health.*;

public class RabbitMQRetryHealthIndicator extends AbstractHealthIndicator
{
    private final RetryCache retryCache;
    private final RetryCacheProperties retryCacheProperties;
    
    public RabbitMQRetryHealthIndicator(final RetryCache retryCache, final RetryCacheProperties retryCacheProperties) {
        this.retryCache = retryCache;
        this.retryCacheProperties = retryCacheProperties;
    }
    
    protected void doHealthCheck(final Health.Builder builder) {
        final int messageSize = this.retryCache.getMessageLocalCache().size();
        if (messageSize >= this.retryCacheProperties.getMaxCapacity()) {
            builder.unknown().withDetail("MessageCache.error", (Object)("\u672a\u786e\u8ba4\u6d88\u606f\u5df2\u8fbe" + this.retryCacheProperties.getMaxCapacity() + "\u6761"));
        }
        else if (messageSize >= this.retryCacheProperties.getAlarmCapacity()) {
            builder.unknown().withDetail("MessageCache.warn", (Object)("\u672a\u786e\u8ba4\u6d88\u606f\u5df2\u8fbe" + this.retryCacheProperties.getAlarmCapacity() + "\u6761"));
        }
        else {
            builder.up().withDetail("MessageCache.size", (Object)messageSize);
        }
    }
}
